<!DOCTYPE html>
<!--suppress ALL-->
<html lang="en" xmlns:v-on="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="stylesheet" type="text/css" th:href="@{/static/h-ui/css/H-ui.min.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/static/h-ui.admin/css/H-ui.admin.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/static/lib/Hui-iconfont/1.0.8/iconfont.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/static/h-ui.admin/skin/default/skin.css}" id="skin"/>
    <link rel="stylesheet" type="text/css" th:href="@{/static/h-ui.admin/css/style.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/static/lib/laypage/1.2/skin/laypage.css}">
    <script type="text/javascript" th:src="@{/static/lib/jquery/1.9.1/jquery.min.js}"></script>
    <script type="text/javascript" th:src="@{/static/lib/layer/2.4/layer.js}"></script>
    <script type="text/javascript" th:src="@{/static/h-ui/js/H-ui.min.js}"></script>
    <script type="text/javascript" th:src="@{/static/h-ui.admin/js/H-ui.admin.js}"></script>
    <script type="text/javascript" th:src="@{/static/lib/My97DatePicker/4.8/WdatePicker.js}"></script>
    <script type="text/javascript" th:src="@{/static/lib/datatables/1.10.0/jquery.dataTables.min.js}"></script>
    <script type="text/javascript" th:src="@{/static/js/laypage/laypage.js}"></script>
    <script th:src="@{/static/lib/vue.min.js}"></script>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 资讯管理 <span
        class="c-gray en">&gt;</span> 资讯列表 <a class="btn btn-success radius r"
                                              style="line-height:1.6em;margin-top:3px"
                                              href="javascript:location.replace(location.href);" title="刷新"><i
        class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <div class="text-c">
        <button onclick="removeIframe()" class="btn btn-primary radius">关闭选项卡</button>
        <!--日期范围：
        <input type="text" onfocus="WdatePicker({ maxDate:'#F{$dp.$D(\'logmax\')||\'%y-%M-%d\'}' })" id="logmin"
               class="input-text Wdate" style="width:120px;">
        -
        <input type="text" onfocus="WdatePicker({ minDate:'#F{$dp.$D(\'logmin\')}',maxDate:'%y-%M-%d' })" id="logmax"
               class="input-text Wdate" style="width:120px;">-->
        请选择查询条件：
        <select id="query">
            <option value="0">-----请选择-----</option>
            <option value="yes">通过</option>
            <option value="refuse">拒绝</option>
            <option value="no">未审核</option>
        </select>
        <button id="aa" class="btn btn-success"><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
    </div>
    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="r">共有数据：<strong id="countCol"></strong> 条</span></div>
    <div class="mt-20" id="list">
        <table class="table table-border table-bordered table-bg table-hover table-sort table-responsive">
            <thead>
            <tr class="text-c">
                <th width="80">编号</th>
                <th width="120">课节标题</th>
                <th width="120">所属课程</th>
                <th width="80">发布时间</th>
                <th width="80">发布人</th>
                <th width="80">价格</th>
                <th width="80">状态</th>
                <th width="120">操作</th>
            </tr>
            </thead>
            <tbody>
            <tr class="text-c" v-for="(item,index) in result">
                <td>{{index+1}}</td>
                <input type="hidden" :value="item.course.courseId" id="courseId">
                <td id="lessionTitle">{{item.lessionTitle}}</td>
                <td>{{item.course.courseName}}</td>
                <td>{{item.lessionTime}}</td>
                <td>{{item.course.teacher.teacherName}}</td>
                <td>{{item.course.coursePrice}}</td>
                <td>{{item.lessionState}}</td>
                <td class="f-14 td-manage"><a style="text-decoration:none" v-if="item.courseFlag === '待审核'" class="ml-5" @click="refuse(item.lessionId)"
                                              title="不通过"><i class="Hui-iconfont">&#xe6dd;</i></a>
                    <a style="text-decoration:none" v-if="item.courseFlag === '待审核'" @click="succ(item.lessionId,item.lessionTitle,item.course.courseId)" class="ml-5" title="通过"><i
                            class="Hui-iconfont">&#xe6e1;</i></a>
                    <a style="text-decoration:none" @click="queryById(item.lessionId)" class="ml-5" title="视频预览"><i
                            class="Hui-iconfont">&#xe715;</i></a>
                </td>
            </tr>
            </tbody>
        </table><br/>
        <div id="pagenav"></div>
    </div>
</div>

</body>

<script th:inline="javascript">
    var app = new Vue({
        el: '#list',
        data: {
            result: []
        }
    });

    var getAllLession = function (curr) {
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: '/admin/getLessionList',
            data: {
                courseId:[[${courseId}]],
                pageSize: 3,
                pageNum: curr || 1,
                state: $("#query").val()
            },
            success: function (data) {
                app.result = data.page.list;
                console.log(data.page.list)
                $("#countCol").html(data.page.total);
                laypage({
                    cont: 'pagenav',
                    skin: '#4169E1',
                    pages: data.totalPage,
                    first: '首页',
                    last: '尾页',
                    curr: curr || 1,
                    jump: function (obj, first) {
                        if (!first) {
                            getAllLession(obj.curr);
                        }
                    }
                })
            }
        })
    };
    getAllLession();

    /*搜索按钮*/
    $("#aa").click(function () {
        getAllLession()
    })

    /*课程审核（同意）*/
    var succ = function (lessionId,lessionTitle,courseId) {
        $.ajax({
            url: "/admin/agree",
            type: 'post',
            dataType: 'json',
            data: {
                lessionId: lessionId,
                courseId: courseId,
                lessionTitle:lessionTitle
            },
            success: function (data) {
                location.replace(location.href)
            }
        })
    }
    /*课程审核（拒绝）*/
    var refuse = function (id) {
        $.ajax({
            url: "/admin/refuse",
            type: 'post',
            dataType: 'json',
            data: {
                lessionId: id
            },
            success: function (data) {
                location.replace(location.href)
            }
        })
    }

    /*查看详情*/
    var queryById = function (id) {

        $.ajax({
            type: "POST",
            url:"/admin/yulan?lessionId="+id,//请求页面
            data: 'lession',
            dataType: "json",
            complete:function(){
                location.href ="/admin/yulan?lessionId="+id
            }//跳转页面
        });
    }

</script>
</html>
